package com.lkd.handler;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lkd.business.MsgHandler;
import com.lkd.config.TopicConfig;
import com.lkd.contract.VendoutContract;
import com.lkd.emq.MqttProducer;
import com.lkd.emq.Topic;
import com.lkd.entity.ChannelEntity;
import com.lkd.service.ChannelService;
import com.lkd.service.VendingMachineService;
import com.lkd.utils.JsonUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.core.CollectionUtils;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;

@Component
@Topic(TopicConfig.VMS_VENDOUT_TOPIC)
@Slf4j
public class VendoutContractMsgHandler implements MsgHandler {

    @Autowired
    private VendingMachineService vendingMachineService;

    /**
     * 接收订单服务的出货消息
     * @param jsonMsg
     * @throws IOException
     */
    @Override
    public void process(String jsonMsg) throws IOException {
        //接收出货消息
        log.info("接收到出货消息"+jsonMsg);
        VendoutContract vendoutContract = JsonUtil.getByJson(jsonMsg, VendoutContract.class);
        //执行出货逻辑
        vendingMachineService.vendout(vendoutContract);
    }


}
